package com.team.app.controller;

import javax.servlet.http.HttpSession;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.team.app.model.Reservation;
import com.team.app.model.Vehicle;
import com.team.app.service.BrandService;
import com.team.app.service.ModelService;
import com.team.app.service.ReservationService;
import com.team.app.service.VehicleService;

/**
 * Handles requests for the application home page.
 */
@Controller
public class ReservationController extends AbstractController<Reservation> {

	private static final Logger logger = LoggerFactory.getLogger(ReservationController.class);

	private final String PATH_BASE = "/reservation";
	@Autowired
	private ReservationService reservationService;
	@Autowired
	private BrandService brandService;
	@Autowired
	private ModelService modelService;
	@Autowired
	private VehicleService vehicleService;

	// -----------------------------------------------------------------------------------
	@Override
	@RequestMapping(value = PATH_BASE, method = { RequestMethod.GET, RequestMethod.POST })
	public String indexAction(Model model,HttpSession s,Reservation obj) {
		logger.info("ReservationController");

		model.addAttribute("brandData", brandService.findAll());

		model.addAttribute("modelData", modelService.findAll());

		return PATH_BASE + "/index";
	}

	@Override
	public String addAction(Model model,HttpSession s) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String editAction(Model model,HttpSession s, Long id) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String confirmAction(Model model,HttpSession s, Reservation obj, BindingResult result) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String completeAction(Model model,HttpSession s, Reservation obj,BindingResult result) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String deleteAction(Model model,HttpSession s, Long id) {
		// TODO Auto-generated method stub
		return null;
	}

	@RequestMapping(value = PATH_BASE + "/search", method = { RequestMethod.GET, RequestMethod.POST })
	public String searchAction(Model model, Long modelId) {
		
		model.addAttribute("obj", new Vehicle());
		
		model.addAttribute("objs", vehicleService.findVehicle(modelId));
		
		return PATH_BASE + "/result-search";
	}

	@Override
	public String backAction(Model model, HttpSession s, Reservation obj) {
		// TODO Auto-generated method stub
		return null;
	}

}
